summaryrefslogtreecommitdiffstats
path: root/src/Scoreboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Scoreboard.cpp')
-rw-r--r--src/Scoreboard.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp
index 7a6ed8867..fad78210e 100644
--- a/src/Scoreboard.cpp
+++ b/src/Scoreboard.cpp
@@ -361,11 +361,15 @@ cTeam * cScoreboard::RegisterTeam(
const AString & a_Prefix, const AString & a_Suffix
)
{
- cTeam Team(a_Name, a_DisplayName, a_Prefix, a_Suffix);
+ auto [TeamIterator, TeamExists] = m_Teams.try_emplace(a_Name, a_Name, a_DisplayName, a_Prefix, a_Suffix);
- std::pair<cTeamMap::iterator, bool> Status = m_Teams.insert(cNamedTeam(a_Name, Team));
+ if (!TeamExists && GetTeam(a_Name))
+ {
+ LOGWARNING("Tried to register a team that already exists: %s", a_Name.c_str());
+ return nullptr;
+ }
- return Status.second ? &Status.first->second : nullptr;
+ return &TeamIterator->second;
}